Skip to content

Comments

Quickfort remaining features#185

Merged
lethosor merged 9 commits intoDFHack:quickfortfrom
myk002:quickfort_remaining
Aug 27, 2020
Merged

Quickfort remaining features#185
lethosor merged 9 commits intoDFHack:quickfortfrom
myk002:quickfort_remaining

Conversation

@myk002
Copy link
Member

@myk002 myk002 commented Aug 23, 2020

DFHack/dfhack#499
the mesh of interdependent feature branches has become too complicated to merge individually, so here's a combined merge for the final milestones for the first public release of DFHack quickfort. Marked WIP until the other PRs (which this PR builds on) are merged. Changes
include:

Major features

  • implement GUI interface for quickfort. can do everything except set settings. remembers last filter and selected position and restores them when GUI is reinvoked.

  • allow multiple blueprints in a single .csv file or spreadsheet sheet. a new blueprint begins when a modeline is detected in the first column.

  • new blueprint mode: zone. Like place mode but for zones. currently can't initialize zone settings (like pit vs pond). will address this later. tricky bit of this mode was ensuring a zone is not selected when it is deleted, since this causes a crash.

  • new blueprint mode: meta. can run a series of related blueprints as if they were one. can also change z-levels and then run a specified blueprint.

  • place and zone mode now recognize multi-type stockpiles and zones.

  • implement new markers for modelines: hidden(), which hides the blueprint from list output unless the --hidden parameter is specified, and label(), which give the blueprint a name. both are primarily useful when writing meta blueprints. you can hide blueprints that are managed by a higher-level meta blueprint, and you need to give your blueprints labels so the meta blueprint can refer to them. also implemented message(), which displays a message to the player after the blueprint has been applied. these markers can be defined in anyhorder.

Bugfixes and minor changes

  • remove the '+' alias for shift. it's too useful of a key to map to something else. also, it seems that the original quickfort only mapped + to shift when it is followed by {Enter}, which is a special case that we don't really want to support. {Shift}{Enter} already has the '@' shortcut.

  • refactor screw pump database entries into a generator function

  • initialize furnaces can accept workshop orders (we correctly initialized real workshops, but furnaces got missed)

  • create quickfort setting 'buildings_use_blocks', which restricts anything that requires a generic building material to instead require a block

  • refactor extent overwriting into a separate function to centralize memory leak protection

  • only output one set of stats per quickfort command invocation instead of one set per (blueprint, zlevel) tuple.

  • move some parsing logic from list.lua to parse.lua to centralize it

  • split do_command() into a frontend and backend so meta blueprints can call the backend function directly

  • refactored the list command into a frontend and backend so the gui can call the backend function directly

  • handle multi-line quoted strings in .csv files

myk002 added 5 commits August 18, 2020 01:13
the mesh of interdependent feature branches has become too complicated
to merge individually, so here's a combined merge for the final
milestones for the first public release of DFHack quickfort. Changes
include:

Major features
--------------

- implement GUI interface for quickfort. can do everything except set
  settings. remembers last filter and selected position and restores
  them when GUI is reinvoked.

- allow multiple blueprints in a single .csv file or spreadsheet sheet.
  a new blueprint begins when a modeline is detected in the first
  column.

- new blueprint mode: zone. Like place mode but for zones. currently
  can't initialize zone settings (like pit vs pond). will address this
  later. tricky bit of this mode was ensuring a zone is not selected
  when it is deleted, since this causes a crash.

- new blueprint mode: meta. can run a series of related blueprints as if
  they were one. can also change z-levels and then run a specified
  blueprint.

- place and zone mode now recognize multi-type stockpiles and zones.

- implement new markers for modelines: hidden(), which hides the
  blueprint from list output unless the --hidden parameter is specified,
  and label(), which give the blueprint a name. both are primarily
  useful when writing meta blueprints. you can hide blueprints that are
  managed by a higher-level meta blueprint, and you need to give your
  blueprints labels so the meta blueprint can refer to them. also
  implemented message(), which displays a message to the player after
  the blueprint has been applied. these markers can be defined in any
  order.

Bugfixes and minor changes
--------------------------

- remove the '+' alias for shift. it's too useful of a key to map to
  something else. also, it seems that the original quickfort only mapped
  + to shift when it is followed by {Enter}, which is a special case
  that we don't really want to support. {Shift}{Enter} already has the
  '@' shortcut.

- refactor screw pump database entries into a generator function

- initialize furnaces can accept workshop orders (we correctly
  initialized real workshops, but furnaces got missed)

- create quickfort setting 'buildings_use_blocks', which restricts
  anything that requires a generic building material to instead require
  a block

- refactor extent overwriting into a separate function to centralize
  memory leak protection

- only output one set of stats per quickfort command invocation instead
  of one set per (blueprint, zlevel) tuple.

- move some parsing logic from list.lua to parse.lua to centralize it

- split do_command() into a frontend and backend so meta blueprints can
  call the backend function directly

- refactored the list command into a frontend and backend so the gui can
  call the backend function directly

- handle multi-line quoted strings in .csv files
Copy link
Member

@lethosor lethosor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested out build mode a bit - the orders/planning/undo support are pretty awesome. Incidentally, this didn't work when I was testing just #182, but it appears that whatever issues were present there are now resolved.

#build
b,,
,b,
,,b

I do have a couple questions:

  • Blueprints in blueprints/library seem to no longer be listed by quickfort list - is this intentional?
  • Moving dreamfort.csv into blueprints gives a bunch of entries like this - is the -n "nil" intentional?
30) "dreamfort.csv" -n "nil" (query: configure rooms); cursor start: staircase center
31) "dreamfort.csv" -n "nil" (dig: ); cursor start: staircase center
32) "dreamfort.csv" -n "nil" (meta: build workshops and stockpiles, configure stockpiles); cursor start: staircase center
36) "dreamfort.csv" -n "nil" (dig: ); cursor start: staircase center
37) "dreamfort.csv" -n "nil" (meta: furniture, stockpiles, hospital, garbage dump); cursor start: staircase center

function enqueue_orders(stats, buildings, building_db, ctx)
local order_specs = ctx.order_specs or {}
ctx.order_specs = order_specs
local reactions = stockflow.reaction_list -- don't cache this; it can reset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this is uninitialized until stockflow's initialize_world() is called, which doesn't happen if the plugin is disabled (I didn't check what happens if it's enabled). I'm not entirely sure if you require stockflow to be enabled, but the current behavior just produces an "unhandled label" error when reaction_list is empty, which I don't think is intentional.

Edit: I guess you could just use reactions = stockflow.collect_reactions() here, actually, to avoid messing with stockflow's internal data (initialize_world() calls clear_cache(), and I don't know if that has unintended side effects)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not a bad idea. no refactoring needed, and no need for the plugin to be enabled -- though can I access the stockflow lua module if the plugin isn't enabled? I'll play with this a bit. At least I can output a proper error message if I need stockflow and it isn't available.

@lethosor lethosor requested a review from a team August 24, 2020 03:05
@lethosor
Copy link
Member

I'm not quite sure why GitHub thinks there are merge conflicts - maybe because of the other merged PRs? I was able to merge this branch into quickfort locally (and vice versa), although I don't want to push the merge up to your branch unless you want me to. I suspect however Git chooses to merge should be fine, but feel free to merge quickfort into this branch and double-check that it's doing the right thing.

@myk002 myk002 changed the title WIP: Quickfort remaining features Quickfort remaining features Aug 24, 2020
@myk002
Copy link
Member Author

myk002 commented Aug 24, 2020

  • Blueprints in blueprints/library seem to no longer be listed by quickfort list - is this intentional?

intentional. I didn't want library files cluttering up the list output. players will usually want to just see their own blueprints. pass -l or --library to quickfort list to see library files.

  • Moving dreamfort.csv into blueprints gives a bunch of entries like this - is the -n "nil" intentional?

very unintentional. and unexpected. I've been testing this extensively while developing the gui. I may have a bad merge somewhere. I'll look into this.

Edit: fixed

@myk002
Copy link
Member Author

myk002 commented Aug 24, 2020

feel free to merge quickfort into this branch and double-check that it's doing the right thing.

merged locally, and no conflicts that I could see.

myk002 added 2 commits August 23, 2020 22:54
ensure marker data is nil when the string is 0-length
fix typo referring to non-existent variable
Copy link
Member

@lethosor lethosor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
The only thing I'd change in the GUI is the colors - you're using COLOR_DARKGREY for labels, which is usually used for disabled labels (I'll change it to COLOR_GREY)

@lethosor lethosor merged commit a6ce52c into DFHack:quickfort Aug 27, 2020
lethosor added a commit to DFHack/dfhack that referenced this pull request Aug 27, 2020
lethosor added a commit that referenced this pull request Aug 27, 2020
@lethosor
Copy link
Member

I see now that you were imitating the built-in shift+enter control in ListBox - I changed that too. I also took advantage of the key_string() wrapper in ef87b3b - turns out it was never documented, but it does simplify the common case of key + ':' + label a bit.

@myk002 myk002 deleted the quickfort_remaining branch August 27, 2020 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants